<?php

class Module {
    static function Init($namespace, $name){
        $ok = false;
        $fielname = MODULES_DIR."/$namespace/$name/$name.module.php";
        
        if(file_exists($fielname)){
            require_once $fielname;
            $ok = true;
        }
        return $ok;
    }
    
    static function Create($ns, $name, $classes = array()){
        array_unshift($classes, ucfirst($name));
        $path = MODULES_DIR."/$ns/$name/$name.module.php";
        $mod_content = "<?".PHP_EOL;
        foreach($classes as $class){
            $classpath = MODULES_DIR."/$ns/$name/classes/$class.class.php";
            $class_content = "<?".PHP_EOL."class $class{}";
            Filesystem::createFile($classpath, $class_content);
            $mod_content .= "IncludeClass(\"$class\", __DIR__.\"/classes\");".PHP_EOL;
        }
        Filesystem::createFile($path, $mod_content);
    }
}
